using MicroMsg.Manager;
using MicroMsg.Resource.@string;
using MicroMsg.UI.Page;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class TXBlogItem : UserControl, MMItemCtrl
	{
		public delegate void ListItemClick(object sender, object object_0);
		public static DependencyProperty ListItemProperty = DependencyProperty.Register("ItemObject", typeof(TXNews), typeof(TXBlogItem), new PropertyMetadata(null, new PropertyChangedCallback(TXBlogItem.OnItemPropertyChanged)));
		internal Grid LayoutRoot;
		internal HttpPicItem picItem;
		internal DynamicTextBlock txtTile;
		internal TextBlock txtUserName;
		internal TextBlock txtTime;
		internal Border border;
		private bool _contentLoaded;
		public event TXBlogItem.ListItemClick ItemClick;
		public TXNews ItemObject
		{
			get
			{
				return (TXNews)base.GetValue(TXBlogItem.ListItemProperty);
			}
			set
			{
				base.SetValue(TXBlogItem.ListItemProperty, value);
			}
		}
		public TXBlogItem()
		{
			this.InitializeComponent();
			this.txtTile.set_Foreground(MMTheme.GetInstance().Brush_BlogTitle);
			this.txtUserName.set_Foreground(MMTheme.GetInstance().Brush_BlogUserName);
			this.txtTime.set_Foreground(MMTheme.GetInstance().CHAT_TIMEINFO_BRUSH);
			this.border.set_Background(MMTheme.GetInstance().Brush_BlogUserName);
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == TXBlogItem.ListItemProperty)
			{
				(dependencyObject_0 as TXBlogItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			try
			{
				this.RefreshItem(dependencyPropertyChangedEventArgs_0.get_NewValue() as TXNews);
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
		}
		private void RefreshItem(TXNews item)
		{
			if (item == null)
			{
				return;
			}
			if (item.isCreateTime)
			{
				this.txtTime.set_Text(item.strSource);
				this.txtTime.set_Visibility(0);
				this.picItem.set_Visibility(1);
				this.txtTile.set_Visibility(1);
				this.txtUserName.set_Visibility(1);
				base.SetValue(MMTiltEffect.IsTiltEnabledProperty, false);
				Panel arg_7D_0 = this.LayoutRoot;
				SolidColorBrush solidColorBrush = new SolidColorBrush();
				solidColorBrush.set_Color(Color.FromArgb(0, 0, 0, 0));
				arg_7D_0.set_Background(solidColorBrush);
				this.border.set_Visibility(1);
				return;
			}
			if (item.isBlankItem)
			{
				this.txtTime.set_Text("");
				this.txtTime.set_Visibility(0);
				this.picItem.set_Visibility(1);
				this.txtTile.set_Visibility(1);
				this.txtUserName.set_Visibility(1);
				base.SetValue(MMTiltEffect.IsTiltEnabledProperty, false);
				Panel arg_104_0 = this.LayoutRoot;
				SolidColorBrush solidColorBrush2 = new SolidColorBrush();
				solidColorBrush2.set_Color(Color.FromArgb(0, 0, 0, 0));
				arg_104_0.set_Background(solidColorBrush2);
				this.border.set_Visibility(1);
				return;
			}
			this.txtTile.set_Visibility(0);
			this.txtUserName.set_Visibility(0);
			this.picItem.set_Visibility(0);
			this.txtTime.set_Visibility(1);
			this.border.set_Visibility(0);
			this.LayoutRoot.set_Background(MMTheme.GetInstance().MultyLink_Brush_Bg2);
			base.SetValue(MMTiltEffect.IsTiltEnabledProperty, true);
			this.txtTile.Text = item.strTitle;
			this.txtUserName.set_Text(item.strSource + " " + strings.blogapp_recommended);
			if (!string.IsNullOrEmpty(item.strIconUrl))
			{
				this.picItem.LoadImage(item.strIconUrl, false);
			}
		}
		private void LayoutRoot_Tap(object sender, GestureEventArgs e)
		{
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.ItemObject);
			}
		}
		public void Refresh()
		{
			this.RefreshItem(this.ItemObject);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/Plugin/TXBlogRead/UI/TXBlogItem.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.picItem = (HttpPicItem)base.FindName("picItem");
			this.txtTile = (DynamicTextBlock)base.FindName("txtTile");
			this.txtUserName = (TextBlock)base.FindName("txtUserName");
			this.txtTime = (TextBlock)base.FindName("txtTime");
			this.border = (Border)base.FindName("border");
		}
	}
}
